﻿<UserControl x:Class="SilverlightGlimpse.Views.GlimpseViewer"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:c="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
             xmlns:converters="clr-namespace:SilverlightGlimpse.Converters"
             xmlns:views="clr-namespace:SilverlightGlimpse.Views"
             xmlns:xaml="clr-namespace:SilverlightGlimpse.Xaml">
    <UserControl.Resources>
        <SolidColorBrush x:Name="noExceptionsFill" Color="SteelBlue" />
        <SolidColorBrush x:Name="noExceptionsBorder" Color="LightBlue" />
        <SolidColorBrush x:Name="hasExceptionsFill" Color="#E51400" />
        <SolidColorBrush x:Name="hasExceptionsBorder" Color="Salmon" />
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot">
        <Grid x:Name="layoutInstrumentPanel">
            <Grid.Resources>
                <Style TargetType="Ellipse">
                    <Setter Property="Width" Value="40" />
                    <Setter Property="Height" Value="40" />
                    <Setter Property="Fill" Value="{xaml:MultiBinding Converter={converters:NumberToBrushConverter}, Source1={Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=DataContext}, Source2={StaticResource noExceptionsFill}, Source3={StaticResource hasExceptionsFill}}" />
                    <Setter Property="Stroke" Value="{xaml:MultiBinding Converter={converters:NumberToBrushConverter}, Source1={Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=DataContext}, Source2={StaticResource noExceptionsBorder}, Source3={StaticResource hasExceptionsBorder}}" />
                    <Setter Property="StrokeThickness" Value="3" />
                    <Setter Property="Margin" Value="7" />
                </Style>
                <Style TargetType="TextBlock">
                    <Setter Property="HorizontalAlignment" Value="Center" />
                    <Setter Property="VerticalAlignment" Value="Center" />
                    <Setter Property="FontSize" Value="12" />
                    <Setter Property="FontWeight" Value="Bold" />
                    <Setter Property="Foreground" Value="White" />
                    <Setter Property="Text" Value="{Binding RelativeSource={RelativeSource AncestorType=Grid}, Path=DataContext}" />
                </Style>
            </Grid.Resources>

            <StackPanel Orientation="Horizontal">
                <Grid DataContext="{Binding BindingErrors.Count}">
                    <Ellipse x:Name="elpBindingErrors" ToolTipService.ToolTip="Binding Exception Count" />
                    <TextBlock x:Name="tbBindingErrors" />
                </Grid>
                <Grid DataContext="{Binding ValidationErrors.Count}">
                    <Ellipse x:Name="elpValidationErrors" ToolTipService.ToolTip="Validation Exception Count" />
                    <TextBlock x:Name="tbValidationErrors" />
                </Grid>
                <Grid DataContext="{Binding Exceptions.Count}">
                    <Ellipse x:Name="elpUnhandledExceptions" ToolTipService.ToolTip="Unhandled Exception Count" />
                    <TextBlock x:Name="tbUnhandledExceptions" />
                </Grid>
                <Button x:Name="btnExpand"
                        Margin="7"
                        VerticalAlignment="Center"
                        Click="btnExpand_Click"
                        Content="Expand" />
            </StackPanel>
        </Grid>

        <Grid x:Name="layoutViewer" Visibility="Collapsed">
            <Grid.RowDefinitions>
                <RowDefinition Height="auto" />
            </Grid.RowDefinitions>

            <StackPanel HorizontalAlignment="Right"
                        VerticalAlignment="Top"
                        Orientation="Horizontal">
                <Button x:Name="btnClear"
                        Width="60"
                        Click="btnClear_Click"
                        Content="Clear" />

                <Button x:Name="btnContract"
                        Width="60"
                        Margin="10,0,0,0"
                        Click="btnContract_Click"
                        Content="Contract" />
            </StackPanel>

            <c:TabControl Width="600" Height="250">

                <c:TabItem Header="{Binding BindingErrors.Count, StringFormat='Bindings ({0})'}">
                    <views:BindingsViewer />
                </c:TabItem>
                <c:TabItem Header="Debug">
                    <views:LogViewer />
                </c:TabItem>
                <c:TabItem Header="{Binding ValidationErrors.Count, StringFormat='Validations ({0})'}">
                    <views:ValidationsViewer />
                </c:TabItem>
                <c:TabItem Header="{Binding Exceptions.Count, StringFormat='Exceptions ({0})'}">
                    <views:ExceptionsViewer />
                </c:TabItem>
            </c:TabControl>

        </Grid>
    </Grid>

</UserControl>
